//
//  NameSP.cpp
//  Practice10
//
//  Created by 赵世杰 on 2020/7/25.
//  Copyright © 2020 zhaoshijie. All rights reserved.
//

#include "NameSP.hpp"
#include <iostream>

using namespace std;


Sales::Sales(const double ar[] , int n)
{
    double sum = 0;
    
    double maxm = ar[0];
    double minm = ar[0];
    
    for (int i=0; i<n; i++)
    {
        double value = ar[i];
        
        sales[i] = value;
        
        sum += value;
        
        if(maxm<value)
        {
            maxm = value;
        }
        
        if(minm>value)
        {
            minm = value;
        }
        
    }
    
    average = sum/n;
    max = maxm;
    min = minm;
    
}

void Sales::showSales()
{
    for (int i=0; i<4; i++)
    {
        cout << i << "季度的营业额为：" << sales[i] << endl;
        
    }
    
    cout << "平均值为：" << average << " 最大值为：" << max << " 最小值为：" << min << endl;

}
